home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / rcs5ap1s.lzh / CONF.SH < prev    next >
Linux/UNIX/POSIX Shell Script  |  1991-01-10  |  16KB  |  707 lines

  1. #!/bin/sh
  2. # Output RCS compile-time configuration.
  3. Id='$Id: conf.sh,v 5.6 90/11/01 05:03:28 eggert Exp $'
  4. #    Copyright 1990 by Paul Eggert
  5. #    Distributed under license by the Free Software Foundation, Inc.
  6.  
  7. # This file is part of RCS.
  8. #
  9. # RCS is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 1, or (at your option)
  12. # any later version.
  13. #
  14. # RCS is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with RCS; see the file COPYING.  If not, write to
  21. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22. #
  23. # Report problems and direct all questions to:
  24. #
  25. #     rcs-bugs@cs.purdue.edu
  26.  
  27.  
  28. # Direct standard output to "a.h"; later parts of this procedure need it.
  29. # Standard error can be ignored if a.h is OK,
  30. # and can be inspected for clues otherwise.
  31. exec >a.h || exit
  32.  
  33. # The Makefile overrides the following defaults.
  34. : ${C='cc -O'}
  35. : ${COMPAT2=0}
  36. : ${DIFF_FLAGS=-an}
  37. : ${DIFF_L=1}
  38. : ${RCSPREFIX=/usr/local/bin/}
  39. : ${SENDMAIL=/usr/lib/sendmail}
  40. : ${L=}
  41. : ${DIFF=${RCSPREFIX}diff}
  42.  
  43.  
  44. cat <<EOF || exit
  45. /* RCS compile-time configuration */
  46.  
  47.     /* $Id */
  48.  
  49. /*
  50.  * This file is generated automatically.
  51.  * If you edit it by hand your changes may be lost.
  52.  * Instead, please try to fix conf.sh,
  53.  * and send your fixes to rcs-bugs@cs.purdue.edu.
  54.  */
  55.  
  56. EOF
  57.  
  58. : exitmain
  59. cat >a.c <<EOF && $C a.c $L >&2 || exit
  60. #include "a.h"
  61. int main(argc,argv) int argc; char **argv; { return argc-1; }
  62. EOF
  63. e='(n) ? (exit(n),(n)) : (n) /* lint fodder */'
  64. if ./a.out -
  65. then :
  66. elif ./a.out
  67. then e=n
  68. fi
  69. echo "#define exitmain(n) return $e /* how to exit from main() */"
  70.  
  71. : standard includes
  72. standardIncludes=
  73. for h in stdio sys/types sys/stat fcntl limits stdlib string unistd vfork
  74. do
  75.     cat >a.c <<EOF || exit
  76. #include "a.h"
  77. $standardIncludes
  78. #include <$h.h>
  79. int main(){ exitmain(0); }
  80. EOF
  81.     if ($C a.c $L && ./a.out) >&2
  82.     then i="#    include <$h.h>"
  83.     else
  84.         case $h in
  85.         string)
  86.             i='#    include <strings.h>';;
  87.         *)
  88.             i="    /* #include <$h.h> does not work.  */"
  89.         esac
  90.     fi || exit
  91.     standardIncludes="$standardIncludes
  92. $i"
  93. done
  94.  
  95. cat <<EOF || exit
  96. #if !MAKEDEPEND$standardIncludes
  97. #endif /* !MAKEDEPEND */
  98. EOF
  99.  
  100. # has_sys_*_h
  101. for H in dir param wait
  102. do
  103.     : has_sys_${H}_h
  104.     cat >a.c <<EOF || exit
  105. #include "a.h"
  106. #include <sys/$H.h>
  107. int main() { exitmain(0); }
  108. EOF
  109.     if ($C a.c $L && ./a.out) >&2
  110.     then h=1
  111.     else h=0
  112.     fi
  113.     echo "#define has_sys_${H}_h $h /* Does #include <sys/$H.h> work?  */"
  114. done
  115.  
  116. : const, volatile
  117. for i in const volatile
  118. do
  119.     cat >a.c <<EOF || exit
  120. #    include "a.h"
  121.     $i int * $i * zero;
  122. EOF
  123.     if $C -S a.c >&2
  124.     then echo "/* #define $i */ /* The '$i' keyword works.  */"
  125.     else echo "#define $i /* The '$i' keyword does not work.  */"
  126.     fi
  127. done
  128.  
  129. # *_t
  130. cat >a.c <<'EOF' || exit
  131. #include "a.h"
  132. #include <signal.h>
  133. t x;
  134. EOF
  135. for t in gid_t mode_t pid_t sig_atomic_t size_t time_t uid_t
  136. do
  137.     : $t
  138.     case $t in
  139.     time_t) i=long;;
  140.     *) i=int;;
  141.     esac
  142.     if $C -S -Dt=$t a.c >&2
  143.     then echo "/* typedef $i $t; */ /* Standard headers define $t.  */"
  144.     else echo "typedef $i $t; /* Standard headers do not define $t.  */"
  145.     fi
  146. done
  147.  
  148. : has_prototypes
  149. cat >a.c <<'EOF' || exit
  150. #include "a.h"
  151. int main(int, char**);
  152. int main(int argc, char **argv) { exitmain(!argv[argc-1]); }
  153. EOF
  154. if $C -S a.c >&2
  155. then h=1
  156. else h=0
  157. fi
  158. cat <<EOF
  159. #define has_prototypes $h /* Do function prototypes work?  */
  160. #if has_prototypes
  161. #    define P(params) params
  162. #    if !MAKEDEPEND
  163. #        include <stdarg.h>
  164. #    endif
  165. #    define vararg_start(ap,p) va_start(ap,p)
  166. #else
  167. #    define P(params) ()
  168. #    if !MAKEDEPEND
  169. #        include <varargs.h>
  170. #    endif
  171. #    define vararg_start(ap,p) va_start(ap)
  172. #endif
  173. EOF
  174.  
  175. : has_getuid
  176. cat >a.c <<'EOF' || exit
  177. #include "a.h"
  178. #ifndef getuid
  179.     uid_t getuid();
  180. #endif
  181. int main() { exitmain(getuid()!=getuid()); }
  182. EOF
  183. if ($C a.c $L && ./a.out) >&2
  184. then h=1
  185. else h=0
  186. fi
  187. echo "#define has_getuid $h /* Does getuid() work?  */"
  188.  
  189. : declare_getpwuid
  190. cat >a.c <<'EOF' || exit
  191. #include "a.h"
  192. #include <pwd.h>
  193. d
  194. int main() { exitmain(!getpwuid(0)); }
  195. EOF
  196. D='struct passwd *getpwuid P((uid_t));'
  197. if ($C -Dd="$D" a.c $L && ./a.out) >&2
  198. then define="#define declare_getpwuid $D"
  199. elif ($C -Dd= a.c $L && ./a.out) >&2
  200. then define="#define declare_getpwuid /* $D */"
  201. else define="/* #define declare_getpwuid $D */"
  202. fi
  203. echo "$define"
  204.  
  205. : has_rename, bad_rename
  206. cat >a.c <<'EOF' && rm -f a.d || exit
  207. #include "a.h"
  208. #ifndef rename
  209.     int rename();
  210. #endif
  211. int main() { exitmain(rename("a.c","a.d")); }
  212. EOF
  213. if ($C a.c $L && ./a.out && test -f a.d) >&2
  214. then
  215.     h=1
  216.     echo x >a.c
  217.     if ./a.out && test ! -f a.c -a -f a.d
  218.     then b=0
  219.     else b=1
  220.     fi
  221. else h=0 b=0
  222. fi
  223. echo "#define has_rename $h /* Does rename() work?  */"
  224. echo "#define bad_rename $b /* Does rename(A,B) fail if B exists?  */"
  225.  
  226. : void, VOID
  227. cat >a.c <<'EOF' || exit
  228. #include "a.h"
  229. void f() {}
  230. int main() {f(); exitmain(0);}
  231. EOF
  232. if $C -S a.c >&2
  233. then
  234.     v='(void) '
  235. else
  236.     v=
  237.     echo 'typedef int void;'
  238. fi
  239. echo "#define VOID $v/* 'VOID e;' discards the value of an expression 'e'.  */"
  240.  
  241. : signal_type, sig_zaps_handler
  242. cat >a.c <<'EOF' || exit
  243. #include "a.h"
  244. #include <signal.h>
  245. #ifndef getpid
  246.     pid_t getpid();
  247. #endif
  248. #ifndef kill
  249.     int kill();
  250. #endif
  251. #ifndef signal
  252.     signal_type (*signal P((int,signal_type(*)P((int)))))P((int));
  253. #endif
  254. signal_type nothing(i) int i; {}
  255. int main(argc, argv) int argc; char **argv;
  256. {
  257.     signal(SIGINT, nothing);
  258.     while (--argc)
  259.         kill(getpid(), SIGINT);
  260.     exitmain(0);
  261. }
  262. EOF
  263. for signal_type in void int bad
  264. do
  265.     case $signal_type in
  266.     bad) echo >&2 "cannot deduce signal_type"; exit 1
  267.     esac
  268.     ($C -Dsignal_type=$signal_type a.c $L && ./a.out 1) >&2 && break
  269. done
  270. echo "#define signal_type $signal_type /* type returned by signal handlers */"
  271. if ./a.out 1 2 >&2
  272. then z=0
  273. else z=1
  274. fi
  275. echo "#define sig_zaps_handler $z /* Must a signal handler reinvoke signal()?  */"
  276.  
  277. : has_seteuid
  278. cat >a.c <<'EOF' || exit
  279. #include "a.h"
  280. #ifndef geteuid
  281.     uid_t geteuid();
  282. #endif
  283. int main() {
  284. /* Guess, don't test.  Ugh.  Testing would require running conf.sh setuid.  */
  285. #if !_POSIX_VERSION || _POSIX_VERSION==198808L&&!defined(sun)&&!defined(__sun__)
  286.     exitmain(1);
  287. #else
  288.     exitmain(seteuid(geteuid()) < 0);
  289. #endif
  290. }
  291. EOF
  292. if ($C a.c $L && ./a.out) >&2
  293. then h=1
  294. else h=0
  295. fi
  296. echo "#define has_seteuid $h /* Does seteuid() obey Posix 1003.1-1990?  */"
  297.  
  298. : has_sigaction
  299. cat >a.c <<'EOF' || exit
  300. #include <signal.h>
  301. struct sigaction s;
  302. EOF
  303. if $C -S a.c >&2
  304. then h=1
  305. else h=0
  306. fi
  307. echo "#define has_sigaction $h /* Does struct sigaction work?  */"
  308.  
  309. : has_sigblock
  310. cat >a.c <<'EOF' || exit
  311. #include "a.h"
  312. #include <signal.h>
  313. #ifndef sigblock
  314.     int sigblock();
  315. #endif
  316. int main() { sigblock(0); exitmain(0); }
  317. EOF
  318. if ($C a.c $L && ./a.out) >&2
  319. then h=1
  320. else h=0
  321. fi
  322. echo "#define has_sigblock $h /* Does sigblock() work?  */"
  323.  
  324. : has_sys_siglist
  325. cat >a.c <<'EOF' || exit
  326. #include "a.h"
  327. #ifndef sys_siglist
  328.     extern const char *sys_siglist[];
  329. #endif
  330. int main() { exitmain(!sys_siglist[1][0]); }
  331. EOF
  332. if ($C a.c $L && ./a.out) >&2
  333. then h=1
  334. else h=0
  335. fi
  336. echo "#define has_sys_siglist $h /* Does sys_siglist[] work?  */"
  337.  
  338. : exit_type, underscore_exit_type
  339. cat >a.c <<'EOF' || exit
  340. #include "a.h"
  341. #ifndef exit
  342.     void exit();
  343. #endif
  344. int main() { exit(0); }
  345. EOF
  346. if $C -S a.c >&2
  347. then t=void
  348. else t=int
  349. fi
  350. echo "#define exit_type $t /* type returned by exit() */"
  351. cat >a.c <<'EOF' || exit
  352. #include "a.h"
  353. #ifndef _exit
  354.     void _exit();
  355. #endif
  356. int main() { _exit(0); }
  357. EOF
  358. if $C -S a.c >&2
  359. then t=void
  360. else t=int
  361. fi
  362. echo "#define underscore_exit_type $t /* type returned by _exit() */"
  363.  
  364. : fread_type
  365. cat >a.c <<'EOF' || exit
  366. #include "a.h"
  367. #ifndef fread
  368.     size_t fread();
  369. #endif
  370. int main() { char b; exit